package com.offcn.login;

import com.offcn.dao.UserDao;
import com.offcn.entity.User;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
//注册
@WebServlet("/register")
public class Register extends HttpServlet {
    UserDao ud = new UserDao();
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取信息
        String username = req.getParameter("username");
        String pwd = req.getParameter("pwd");
        String name = req.getParameter("name");
        String tel = req.getParameter("tel");
        String bir = req.getParameter("bir");
        //存入数据库
        User u = new User(username,pwd,name,tel,DateUtil.dateformat(bir));
        boolean b = ud.register(u);
        if(b){
            resp.sendRedirect("index.jsp");
        }else {
            resp.sendRedirect("register.jsp");
        }

    }
}
